﻿using DocumentFormat.OpenXml.Bibliography;
using MOKA.TPM.Utility.Const;
using SqlSugar;
using System.ComponentModel.DataAnnotations;

namespace MOKA.TPM.Entity;

/// <summary>
/// 资产
/// </summary>
[Tenant(TPMConst.TPMConfigId)]
[SugarTable("Asset", "资产")]
public class Asset
{
    /// <summary>
    /// 序号
    /// </summary>
    [SugarColumn(ColumnName = "Id", ColumnDescription = "序号", IsPrimaryKey = true)]
    public Guid Id { get; set; }

    /// <summary>
    /// 资产编号
    /// </summary>
    [SugarColumn(ColumnName = "AssetNo", ColumnDescription = "资产编号", Length = 50)]
    [Required, MaxLength(50)]
    public string AssetNo { get; set; } = string.Empty;

    /// <summary>
    /// 资产名称
    /// </summary>
    [SugarColumn(ColumnName = "AssetName", ColumnDescription = "资产名称", Length = 50)]
    [Required, MaxLength(50)]
    public string AssetName { get; set; } = string.Empty;

    /// <summary>
    /// 公司代码
    /// </summary>
    [SugarColumn(ColumnName = "CompanyCode", ColumnDescription = "公司代码", Length = 50)]
    [Required, MaxLength(50)]
    public string CompanyCode { get; set; } = string.Empty;

    /// <summary>
    /// 公司名称
    /// </summary>
    [SugarColumn(ColumnName = "CompanyName", ColumnDescription = "公司名称", Length = 50)]
    [Required, MaxLength(50)]
    public string CompanyName { get; set; } = string.Empty;

    /// <summary>
    /// TPM设备分组（MES）
    /// </summary>
    [SugarColumn(ColumnName = "TPMDeviceGroupId", ColumnDescription = "TPM设备分组（MES）")]
    public Guid TPMDeviceGroupId { get; set; }

    /// <summary>
    /// 资产大类代码
    /// </summary>
    [SugarColumn(ColumnName = "CategoryCode", ColumnDescription = "资产大类代码", Length = 50)]
    [Required, MaxLength(50)]
    public string CategoryCode { get; set; } = string.Empty;

    /// <summary>
    /// 资产大类名称
    /// </summary>
    [SugarColumn(ColumnName = "CategoryName", ColumnDescription = "资产大类名称", Length = 50)]
    [Required, MaxLength(50)]
    public string CategoryName { get; set; } = string.Empty;

    /// <summary>
    /// 资产细类代码
    /// </summary>
    [SugarColumn(ColumnName = "TypeCode", ColumnDescription = "资产细类代码", Length = 50)]
    [Required, MaxLength(50)]
    public string TypeCode { get; set; } = string.Empty;

    /// <summary>
    /// 资产细类名称
    /// </summary>
    [SugarColumn(ColumnName = "TypeName", ColumnDescription = "资产细类名称", Length = 50)]
    [Required, MaxLength(50)]
    public string TypeName { get; set; } = string.Empty;

    /// <summary>
    /// 型号
    /// </summary>
    [SugarColumn(ColumnName = "Model", ColumnDescription = "型号", Length = 50)]
    [Required, MaxLength(50)]
    public string Model { get; set; } = string.Empty;

    /// <summary>
    /// 资产状态
    /// </summary>
    [SugarColumn(ColumnName = "Status", ColumnDescription = "资产状态", Length = 20)]
    [Required, MaxLength(20)]
    public string Status { get; set; } = string.Empty;

    /// <summary>
    /// 资本化日期
    /// </summary>
    [SugarColumn(ColumnName = "CapitalizationDate", ColumnDescription = "资本化日期")]
    public DateTime? CapitalizationDate { get; set; }

    /// <summary>
    /// 报废日期
    /// </summary>
    [SugarColumn(ColumnName = "ScrapDate", ColumnDescription = "报废日期")]
    public DateTime? ScrapDate { get; set; }

    /// <summary>
    /// 供应商代码
    /// </summary>
    [SugarColumn(ColumnName = "SupplierCode", ColumnDescription = "供应商代码", Length = 50)]
    [Required, MaxLength(50)]
    public string SupplierCode { get; set; } = string.Empty;

    /// <summary>
    /// 供应商名称
    /// </summary>
    [SugarColumn(ColumnName = "SupplierName", ColumnDescription = "供应商名称", Length = 50)]
    [Required, MaxLength(50)]
    public string SupplierName { get; set; } = string.Empty;

    /// <summary>
    /// 成本中心代码
    /// </summary>
    [SugarColumn(ColumnName = "CostCenterCode", ColumnDescription = "成本中心代码", Length = 50)]
    [Required, MaxLength(50)]
    public string CostCenterCode { get; set; } = string.Empty;

    /// <summary>
    /// 成本中心名称
    /// </summary>
    [SugarColumn(ColumnName = "CostCenterName", ColumnDescription = "成本中心名称", Length = 50)]
    [Required, MaxLength(50)]
    public string CostCenterName { get; set; } = string.Empty;

    /// <summary>
    /// 一级部门
    /// </summary>
    [SugarColumn(ColumnName = "DepartmentLv1", ColumnDescription = "一级部门", Length = 50)]
    [MaxLength(50)]
    public string? DepartmentLv1 { get; set; }

    /// <summary>
    /// 二级部门
    /// </summary>
    [SugarColumn(ColumnName = "DepartmentLv2", ColumnDescription = "二级部门", Length = 50)]
    [MaxLength(50)]
    public string? DepartmentLv2 { get; set; }

    /// <summary>
    /// 使用部门（MES）
    /// </summary>
    [SugarColumn(ColumnName = "UserDepartmentID", ColumnDescription = "使用部门（MES）", Length = 50)]
    [MaxLength(50)]
    public string? UserDepartmentID { get; set; }

    /// <summary>
    /// 资产管理员工号
    /// </summary>
    [SugarColumn(ColumnName = "ManagerNo", ColumnDescription = "资产管理员工号", Length = 50)]
    [Required, MaxLength(50)]
    public string ManagerNo { get; set; } = string.Empty;

    /// <summary>
    /// 资产管理员姓名
    /// </summary>
    [SugarColumn(ColumnName = "ManagerName", ColumnDescription = "资产管理员姓名", Length = 50)]
    [Required, MaxLength(50)]
    public string ManagerName { get; set; } = string.Empty;

    /// <summary>
    /// 资产使用人工号
    /// </summary>
    [SugarColumn(ColumnName = "UserNo", ColumnDescription = "资产使用人工号", Length = 50)]
    [Required, MaxLength(50)]
    public string UserNo { get; set; } = string.Empty;

    /// <summary>
    /// 资产使用人姓名
    /// </summary>
    [SugarColumn(ColumnName = "UserName", ColumnDescription = "资产使用人姓名", Length = 50)]
    [Required, MaxLength(50)]
    public string UserName { get; set; } = string.Empty;

    /// <summary>
    /// 资产使用人工号（MES）
    /// </summary>
    [SugarColumn(ColumnName = "UserNo_MES", ColumnDescription = "资产使用人工号（MES）", Length = 50)]
    [Required, MaxLength(50)]
    public string UserNo_MES { get; set; } = string.Empty;

    /// <summary>
    /// 资产使用人姓名（MES）
    /// </summary>
    [SugarColumn(ColumnName = "UserName_MES", ColumnDescription = "资产使用人姓名（MES）", Length = 50)]
    [Required, MaxLength(50)]
    public string UserName_MES { get; set; } = string.Empty;

    /// <summary>
    /// 库存地点
    /// </summary>
    [SugarColumn(ColumnName = "Position", ColumnDescription = "库存地点", Length = 100)]
    [Required, MaxLength(100)]
    public string Position { get; set; } = string.Empty;

    /// <summary>
    /// 库存地点（MES）
    /// </summary>
    [SugarColumn(ColumnName = "Position_MES", ColumnDescription = "库存地点（MES）", Length = 100)]
    [Required, MaxLength(100)]
    public string Position_MES { get; set; } = string.Empty;

    /// <summary>
    /// 数量
    /// </summary>
    [SugarColumn(ColumnName = "Qty", ColumnDescription = "数量")]
    public int Qty { get; set; }

    /// <summary>
    /// 图片（MES）
    /// </summary>
    [SugarColumn(ColumnName = "Picture", ColumnDescription = "图片（MES）")]
    public byte[] Picture { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [SugarColumn(ColumnName = "Remark", ColumnDescription = "备注", Length = 100)]
    [MaxLength(100)]
    public string? Remark { get; set; }

    /// <summary>
    /// SAP创建时间
    /// </summary>
    [SugarColumn(ColumnName = "CreateTimeInSAP", ColumnDescription = "SAP创建时间")]
    public DateTime? CreateTimeInSAP { get; set; }

    /// <summary>
    /// SAP更新时间
    /// </summary>
    [SugarColumn(ColumnName = "UpdateTimeInSAP", ColumnDescription = "SAP更新时间")]
    public DateTime? UpdateTimeInSAP { get; set; }

    /// <summary>
    /// SAP同步时间
    /// </summary>
    [SugarColumn(ColumnName = "SyncTime", ColumnDescription = "SAP同步时间")]
    public DateTime? SyncTime { get; set; }

    /// <summary>
    /// 创建用户
    /// </summary>
    [SugarColumn(ColumnName = "CreateUser", ColumnDescription = "创建用户", Length = 20)]
    [Required, MaxLength(20)]
    public string CreateUser { get; set; } = string.Empty;

    /// <summary>
    /// 创建时间
    /// </summary>
    [SugarColumn(ColumnName = "CreateTime", ColumnDescription = "创建时间")]
    public DateTime CreateTime { get; set; }

    /// <summary>
    /// 更新用户
    /// </summary>
    [SugarColumn(ColumnName = "UpdateUser", ColumnDescription = "更新用户", Length = 20)]
    [MaxLength(20)]
    public string? UpdateUser { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    [SugarColumn(ColumnName = "UpdateTime", ColumnDescription = "更新时间")]
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// UserDepartmentID (使用部门（MES）) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(UserDepartmentID), nameof(Department.DepartmentId))]//多对一
    public Department department_UserDepartmentID { get; set; }

    /// <summary>
    /// TPMDeviceGroupId (TPM设备分组（MES）) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(TPMDeviceGroupId), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_TPMDeviceGroupId { get; set; }

    /// <summary>
    /// CreateUser (创建用户) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CreateUser), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_CreateUser { get; set; }

    /// <summary>
    /// UpdateUser (更新用户) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(UpdateUser), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_UpdateUser { get; set; }

    /// <summary>
    /// 子表：生产设备
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(Equipment.AssetId))]//一对多
    public List<Equipment> Equipments { get; set; }
}